package com.lagou.edu.servlet;

import server.HttpProtocolUtil;
import server.HttpServlet;
import server.Request;
import server.Response;

import java.io.IOException;

/**
 * @ClassName : Demo1Servlet
 * @Description : Servlet
 * @Author : zhangxiaohai
 * @Date: 2021-06-23 22:29
 */
public class Demo1Servlet extends HttpServlet {

    @Override
    public void doGet(Request request, Response response) {
        String content = "<p>Demo1Servlet get 请求</p>";
        try {
            response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void doPost(Request request, Response response) {
        String content = "<p>Demo1Servlet post 请求</p>";
        try {
            response.output((HttpProtocolUtil.getHttpHeader200(content.getBytes().length) + content));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void init() throws Exception {
        System.out.println("Demo1Servlet init。。。。。");
    }

    @Override
    public void destory() throws Exception {

    }
}
